home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
prog
/
rtmem100.zip
/
RTMEM.DOC
< prev
Wrap
Text File
|
1992-01-10
|
13KB
|
306 lines
RTMEM 1.00
Purpose
-------
RTMEM (Run-Time MEMory) is a programmer's diagnostic aid that allows
you to easily run programs with a specific amount of free memory
available. It is easier to use than the traditional "memory eaters"
and more accurate than loading other programs, adjusting BUFFERS,
etc., simply to take up space.
Background
----------
It is not at all uncommon for a program to operate correctly on the
developer's system but fail on a user's system. There are many
possible causes for this situation; one of these is that the user's
system has a different amount of DOS memory available for the
program.
The traditional approach to analyzing whether or not this is the
case is to reduce the developer's system's free memory in one way or
another, then run the program to see if it fails. This is typically
accomplished by loading multiple copies of COMMAND.COM or DEBUG, by
increasing FILES and/or BUFFERS, by running the program from the
"shell" option of an application, or by using tools such as Turbo
Power Software's EATMEM.
The problem with adjusting BUFFERS or loading other programs before
running the target is that it's hard to "eat" just the right amount
of memory; and unless you have exactly the right amount of free RAM,
you may not see the problem. EATMEM is better, but it has two
problems. First, it's still rather coarse (allocations are made in
units of K-bytes). Second, it's a TSR. Once memory has been
"eaten" by EATMEM, you can't get it back without either rebooting or
using a TSR manager such as MARK/RELEASE.
RTMEM solves these problems; it allows you to specify the exact
amount of free memory you want available to the target program, and
it is not a TSR. After running the target program, you still have
all of your original DOS memory free.
Use
---
Usage of RTMEM is very simple:
RTMEM memorysize d:\path\name.exe [parameters]
The first argument is the amount of free memory you want available
to the target program (NOT the amount of memory you want RTMEM to
"eat"). It is specified in bytes, not KB or paragraphs. Note,
however, that DOS allocates memory in units of paragraphs (16
bytes); RTMEM will round up to the next paragraph if you specify a
number that is not a multiple of 16 bytes. For ease of data entry,
you can include commas in the memory size; RTMEM will ignore them.
The second argument is the fully-qualified name of the program you
want to run: the drive, path, name and extension. You can omit the
drive and/or path only if the program is located in the default
drive and/or path; RTMEM does not search the system PATH.
Following the program name are any parameters required for operation
of the program (i.e., the same parameters/options you would use to
run the program without RTMEM).
Examples:
RTMEM 314992 c:\arf\foo.exe /d /e
This example runs C:\ARF\FOO.EXE with 314,992 bytes of free memory.
The options "/d /e" are passed along to FOO.EXE.
RTMEM 145,008 c:\dos\mem.exe
This example runs MEM.EXE with 145,008 bytes of free memory. The
display from MEM.EXE shows the following when run on our system with
this command:
655360 bytes total conventional memory
655360 bytes available to IBM DOS
145008 largest executable program size <---
Before running the program, RTMEM displays the segment address at
which the target program will load:
Target program will load at 7F09
This message indicates that the program will be loaded at segment
7F09 (hex). This will be the address of the program's PSP, not of
its environment.
When the target program terminates, RTMEM regains control and
returns to DOS, releasing any memory that it has allocated.
Environment
-----------
The question arises, "what about the system environment?" Suppose
a customer reports that your program fails on his system and the
running MEM indicates 542,496 bytes of free memory. You can easily
run
RTMEM 542,496 c:\myprog.exe
But what if your DOS environment is not the same size as your
customer's? If your environment is 1K larger than his, doesn't that
mean that using the same size will actually result in 1K less memory
available to the program on your system than on his?
In general, the answer is "no," if you are using either MEM or
CHKDSK to report free memory. Both of these programs report the
amount of memory that will be available to run a program AFTER space
has been allocated for the current environment. RTMEM also follows
this convention; in other words, if you tell it to allow X bytes of
free memory for a program, it assumes you mean X bytes of memory
free AFTER the new environment has been allocated. Therefore, use
the exact number reported by either MEM or CHKDSK when running
RTMEM.
Running under a debugger
------------------------
Once you have determined that memory size is indeed the problem, you
may need to run the target program (with the correct memory size)
under a debugger. The problem is, of course, that the debugger
takes some memory.
There are several ways to approach this problem. Here is one:
1. Run RTMEM with no arguments except /L:
RTMEM /L
With /L, RTMEM simply displays its own load address and then
terminates:
RTMEM is loaded at 0BCB [for example]
Make a note of this address.
2. Load the target program under your debugger; display the CPU
registers and make a note of the value contained in the DS
register. This is the segment address at which your debugger
has loaded the target program. NOTE: use the full path to your
debugger when you run it; this is necessary to ensure that
the debugger's environment is the same size it will be when you
run it under RTMEM later.
3. Subtract the RTMEM /L load address from the DS value. Since
the debugger and RTMEM loaded at the same address, the
difference between DS and the address displayed by RTMEM /L
represents the size of the debugger (in paragraphs), including
any memory it has taken for symbol storage, etc.
4. Convert the number calculated in step 3 to decimal, and
multiply it by 16. This is the amount of memory consumed by the
debugger, in bytes.
5. Add the value from step 4 to the desired memory size for the
target program.
6. Run your debugger under RTMEM, using the value calculated in
step 5.
For example, suppose you want to run C:\ARF\FOO.EXE under DEBUG with
135,008 bytes of free memory. Running:
RTMEM 135008 C:\ARF\FOO.EXE
has confirmed that there is a problem in FOO when this amount of
memory is available. The steps above might look like this:
1. Run RTMEM /L:
C> RTMEM /L
RTMEM is loaded at 05D7
2. Run DEBUG:
C> C:\DOS\DEBUG.COM C:\ARF\FOO.EXE
Display the registers:
AX=0000 BX=0000 ...
DS=0BCB ES=0BCB ...
Note the DS value (0BCB).
3. Subtract the RTMEM /L address from DEBUG's DS:
0BCB - 05D7 = 05F4
DEBUG is using 05F4 paragraphs of memory.
4. Convert 05F4 to decimal (1524) and multiply by 16; the result
is 24384, which is the amount of memory DEBUG is using, in
bytes.
5. Add the result from step 4 to the desired free memory for
FOO.EXE:
135008 + 24384 = 159392
6. Run FOO under DEBUG under RTMEM with the value from step 5:
C> RTMEM 159392 C:\DOS\DEBUG.COM C:\ARF\FOO.EXE
FOO should now have 135008 bytes of memory available (159392 less
the 24384 bytes being used by DEBUG).
To confirm, note the initial value of DS when the target program is
loaded under your debugger. This should be the same value displayed
by RTMEM if you run the target program directly (without the
debugger) and specify the desired memory size. In our example:
C> RTMEM 135008 C:\ARF\FOO.EXE
target program will load at 7F09
...
C> RTMEM 159392 C:\DOS\DEBUG.COM C:\ARF\FOO.EXE
-R
AX=0000 BX=0000 ...
DS=7F09 ES=7F09 ...
Note that the value of DEBUG's DS is the same as the load address
displayed by RTMEM.
Error messages
--------------
RTMEM reports the following errors:
requested size greater than available memory
The memory size you specified on the command line is greater
than the amount of memory currently available. RTMEM can only
decrease free memory, not increase it.
program not found (remember to use path and extension)
RTMEM was unable to find the target program. Be sure that you
have specified everything it needs to find the program: the
drive (if the program is not on the current drive), the
directory (if the program is not in the current directory), and
the program name AND extension. Do not rely on the PATH.
requested size is not enough to run the program
RTMEM could not run the target program due to insufficient
memory; in other words, you executed "RTMEM 50000 foo.exe",
and FOO.EXE cannot run in 50,000 bytes of memory.
error running program
Catch-all message for other errors encountered in attempting
to run the program. You should not see this message...
memory size specified greater than 1MB
Just what it says: you specified a memory size larger than 1MB.
COPYRIGHT/LICENSE/WARRANTY
--------------------------
This document and the program file RTMEM.COM ("the software") are
Copyright (C) 1992
The Cove Software Group
All Rights Reserved
The copyright owner hereby licenses you to: use the software except
as below; make as many copies of the program and documentation as
you wish; give such copies to anyone; and distribute the software
and documentation via electronic means. There is no charge for any
of the above.
You are specifically prohibited from charging, or requesting
donations, for any such copies, however made; and from distributing
the software and/or documentation with commercial products without
prior permission in writing from the copyright owner.
Persons and organizations who are engaged in the distribution of
shareware, "freeware", and/or public domain software may include RTMEM
on distribution disks as long as charges are made on a per-disk
basis rather than a per-program basis. The charge per disk may not
exceed $7 US. Such persons and organizations must not represent
themselves as vendors, distributors, or sellers of RTMEM.
RTMEM may not be used in a commercial, governmental, or institutional
environment. It is intended for personal use only. Other users
should contact us for licensing information.
No copy of the software may be distributed without this document;
and the contents of the document must not be altered.
There is no warranty of any kind, and the copyright owner is not
liable for damages of any kind. By using this free software, you
agree to this.
-------------------------------
The Cove Software Group
Post Office Box 1072
Columbia, MD 21044
410/992-9371
CompuServe: 76703,2002
Program and documentation author:
Christoper J. Dunford